package top.jnaw.jee.platform;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.kit.PropKit;
import top.jnaw.jee.utils.qiniu.PropertyUtil;

public class Consts {

  public static final boolean LOCAL_SERVER = false;

  public static final String PROJECT_NAME = PropKit.get("project_name", "");
  public static final String LINK = PropKit.get("link", "");

  public static final String NIM_KEY = PropKit.get("nim_app_key", "");
  public static final String NIM_SECRET = PropKit.get("nim_app_secret", "");

  public static final String NIM_SMS_KEY = PropKit.get("nim_sms_app_key", "");
  public static final String NIM_SMS_SECRET = PropKit
      .get("nim_sms_app_secret", "");

  public static final String JPUSH_MASTER_SECRET = PropKit
      .get("jpush_master_secret", "");
  public static final String JPUSH_APP_KEY = PropKit.get("jpush_app_key", "");

  public static final String WECHAT_APPID = PropKit.get("wechat_appid");
  public static final String WECHAT_SECRET = PropKit.get("wechat_secret");

  public static final String DOMAIN = PropKit.get("domain_url");

  public static final String WECHAT_REDIRECT_URL =
      PropKit.get("domain_url") + PropKit.get("project_name") + PropKit
          .get("wechat_redirect_url");
  public static final String ENCODE = "UTF-8";

  public static final String CACHE_NAME = PropKit.get("cache_name", "");

  public static final int DEFAULT_BAD_ID = -1;
  public static final double DEFAULT_DOUBLE = 0.0f;
  public static final float DEFAULT_FLOAT = 0.0f;
  public static final int DEFAULT_PAGE = 1;
  public static final int DEFAULT_PAGE_SIZE = PropKit
      .getInt("paginate_size", 10);
  public static final String JSON_RES_RESULT = "result";
  public static final String JSON_RES_DATA = "data";
  public static final String JSON_RES_PAGE = "page";
  public static final String JSON_RES_SIZE = "size";
  public static final String JSON_RES_ROWS = "rows";
  public static final String JSON_RES_TOTAL = "total";

  public static final String WECHAT_CODE = "errcode";
  public static final String WECHAT_MSG = "errmsg";

  public static final String ACCESS_TOKEN = "access_token";
  public static final String TICKET = "ticket";
  public static final String OPENID = "openid";

  public static final String UPLOAD_FOLDER = LOCAL_SERVER ? PropKit
      .get("upload_local_folder") : PropKit.get("upload_folder");
  public static final String UPLOAD_APP = LOCAL_SERVER ? PropKit
      .get("upload_local_app") : PropKit.get("upload_app");
  public static final String UPLOAD_QINIU = LOCAL_SERVER ? PropKit
      .get("upload_local_QiNiu") : PropKit.get("upload_QiNiu");
  public static final String UPLOAD_URL_BASE = PropKit.get("upload_url_base");

  public static final String DATE_UP_TO_NOW = "-";

  public static final String PATTERN_DATE = "yyyy-MM-dd";
  public static final String PATTERN_MOUTH = "yyyy-MM";
  public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss";
  public static final String PATTERN_DATETIME_HH_MM = "yyyy-MM-dd HH:mm";

  public static final JSONObject EMPTY_OBJECT = new JSONObject();
  public static final JSONArray EMPTY_ARRAY = new JSONArray();
  //手机号正则匹配

  public static final String REGEX_MOBILE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";

  //  QiNiu
  public static final String bucketName = PropertyUtil
      .getProperty("bucketName");
  public static final String domain = PropertyUtil.getProperty("domain");
  public static final String ACCESS_KEY = PropertyUtil
      .getProperty("ACCESS_KEY");
  public static final String SECRET_KEY = PropertyUtil
      .getProperty("SECRET_KEY");

  // 项目ID(公共应用ID),正式环境下贵司将拥有独立的应用ID
  public static final String PROJECT_ID = PropKit.get("PROJECT_ID");
  // 项目Secret(公共应用Secret),正式环境下贵司将拥有独立的应用Secret
  public static final String PROJECT_SECRET = PropKit.get("PROJECT_SECRET");

  // 协议类型(可选HTTP或HTTPS)
//  public static final HttpType HTTP_TYPE = HttpType.HTTP;
//  // 算法类型(可选HMACSHA256或RSA)，但推荐使用HMACSHA256
//  public static final AlgorithmType ALGORITHM_TYPE = AlgorithmType.HMACSHA256;

  // e签宝公钥，可以从开放平台获取。若算法类型为RSA，此项必填
  public static final String ESIGN_PUBLIC_KEY = null;
  // 平台私钥，可以从开放平台下载密钥生成工具生成。若算法类型为RSA，此项必填
  public static final String PRIVATE_KEY = null;

  public enum Result {
    kSuccess,
    kNext, kUnLogin, kUnauthorized, kBadCaptcha,
    kBadParam, kException, kNull, kNIMError, kShiroError,
    kModelError, kModelSaveError, kModelUpdateError, kModelDeleteError,
    kFileWithoutPermit, kFileCopyError, kImageThumbError, kBadLength, kBadType, kBadLocalCode,
    kBadBirthday, kBadCheck, kBadYear, kBadMonth, kBadDay, kRegistered, kBadId, Resigned, kTimeError
  }

  public enum ModelResultType {
    kNormal,
    kObject, kArray,
  }
}
